package com.banciyuan.bcywebview.biz.main.newdiscover.index.decoration;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Rect;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.banciyuan.bcywebview.utils.common.UIUtils;

/**
 * Created by squall on 2017/3/22.
 */

public class DiscoverDecoration extends RecyclerView.ItemDecoration {

    private Context mContext;

    public DiscoverDecoration(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        RecyclerView.Adapter adapter = parent.getAdapter();
        if (adapter != null) {
            int type = adapter.getItemViewType(parent.getChildAdapterPosition(view));
            if (type != 0 && type != 1 && type != 11) {
                if ((parent.getChildAdapterPosition(view)) % 2 == 0) {
                    outRect.left = UIUtils.dip2px(4, mContext);
                    outRect.right = UIUtils.dip2px(12, mContext);
                } else {
                    outRect.left = UIUtils.dip2px(12, mContext);
                    outRect.right = UIUtils.dip2px(4, mContext);
                }
            }
        }
    }

    @Override
    public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
        c.drawColor(Color.WHITE);
    }
}
